package br.net.atasacramental.menu.dao;
import br.net.atasacramental.menu.model.Menu;
import br.net.atasacramental.util.ConexaoDB;

import java.util.List;
import java.util.HashMap;
import java.util.Map;
/**
* @author alexandre.araujo
*/
public class MenuDAO{
	private String[][] ordemP = {{"ordem", "asc"}};
	@SuppressWarnings("unchecked")
    public List<Menu> get() {
        return (List<Menu>) ConexaoDB.get(Menu.class,true,1,100,null,ordemP);
    }
    public Menu getByIdMenu(int idMenu) {
        return (Menu) ConexaoDB.getById(Menu.class, idMenu);
    }    
    @SuppressWarnings("unchecked")
    public List<Menu> getByLabel(String label) {    	
     	Map<String,Object> params = new HashMap<String, Object>();
     	params.put("label",label);
        return (List<Menu>) ConexaoDB.get(Menu.class,true,1,100,params,ordemP);
    }
    @SuppressWarnings("unchecked")
    public List<Menu> getByOrdem(int ordem) {
     	Map<String,Object> params = new HashMap<String, Object>();
     	params.put("ordem", ordem);
        return (List<Menu>) ConexaoDB.get(Menu.class,true,1,100,params,ordemP);
    }
    public boolean insert(Menu m){
        return ConexaoDB.insert(m);
    }
    public boolean update(Menu m){
        return ConexaoDB.update(m);
    }
    public boolean delete(Menu m){
        return ConexaoDB.delete(m);
    }
}
